<?php /*a:1:{s:76:"/Users/juyaobin/Desktop/Site/app/useradmin/view/app/AppList/EditAppList.html";i:1615122209;}*/ ?>
<html>

<head>
    <meta charset="UTF-8" />
    <meta name="renderer" content="webkit" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport"
        content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>网站后台管理模版</title>
    <script src="/public/static/admin/imgupdate/jquery.min.js"></script>
    <link rel="stylesheet" type="text/css" href="/static/admin/layui/css/layui.css" />
    <link rel="stylesheet" type="text/css" href="/static/admin/css/admin.css" />
    <script src="/public/static/other.js"></script>
    <script src="/public/static/tisp.js"></script>
</head>

<body>
    <div class="page-content-wrap">
        <form class="layui-form">
            <div class="layui-tab" style="margin: 0">

                <div class="layui-tab-content">
                    <div class="layui-tab-item"></div>
                    <div class="layui-tab-item layui-show">
                        <div class="layui-form-item">
                            <label class="layui-form-label">类型：</label>
                            <div class="layui-input-block">
                                <select id="platform" lay-verify="required">
                                    <option value="">桌面端</option>
                                    <optgroup label="移动端">
                                        <option value="0" selected="">IOS</option>
                                        <option value="1">Android</option>
                                    </optgroup>
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">密钥：</label>
                            <div class="layui-input-block">
                                <input type="text" id="key" lay-verify="required" placeholder="请输入版本" autocomplete="off"
                                    class="layui-input NumDecText" value="" />

                            </div>
                        </div>
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">私钥：</label>
                            <div class="layui-input-block">
                                <input type="text" id="private_key" lay-verify="required" placeholder="请输入版本"
                                    autocomplete="off" class="layui-input NumDecText" value="" />

                            </div>
                        </div>
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">版本：</label>
                            <div class="layui-input-block">
                                <input type="text" id="version" lay-verify="required" placeholder="请输入版本"
                                    autocomplete="off" class="layui-input NumDecText" value="" />

                            </div>
                        </div>
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">编译版本：</label>
                            <div class="layui-input-block">
                                <input type="text" id="build_version" lay-verify="required" placeholder="请输入编译版本"
                                    autocomplete="off" class="layui-input NumDecText" value="" />

                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">文件上传：</label>
                            <div class="layui-input-block">
                                <div style="display: flex;" class="layui-box layui-upload-button">

                                    <div style="width: 100%;" class="layui-inline">
                                        <input type="text" id="download_url" lay-verify="required"
                                            placeholder="请输入下载地址或上传文件" autocomplete="off" class="layui-input">
                                    </div>
                                    <div class="layui-inline">
                                        <button type="button" class="layui-btn" id="update-file">
                                            <i class="layui-icon">&#xe67c;</i>
                                            上传安装包
                                        </button>
                                    </div>



                                </div>
                            </div>
                        </div>

                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">更新日志：</label>
                            <div class="layui-input-block">
                                <textarea class="layui-textarea layui-hide" name="content" lay-verify="content"
                                    id="update_info"></textarea>
                                <div class="layui-layedit">
                                    <div class="layui-unselect
                                            layui-layedit-tool">
                                        <i class="layui-icon
                                                layedit-tool-b" title="加粗" lay-command="Bold" layedit-event="b"></i>
                                        <i class="layui-icon
                                                layedit-tool-i" title="斜体" lay-command="italic" layedit-event="i"></i>
                                        <i class="layui-icon
                                                layedit-tool-u" title="下划线" lay-command="underline"
                                            layedit-event="u"></i>
                                        <i class="layui-icon
                                                layedit-tool-d" title="删除线" lay-command="strikeThrough"
                                            layedit-event="d"></i>
                                        <span class="layedit-tool-mid"></span>
                                        <i class="layui-icon
                                                layedit-tool-left" title="左对齐" lay-command="justifyLeft"
                                            layedit-event="left"></i>
                                        <i class="layui-icon
                                                layedit-tool-center" title="居中对齐" lay-command="justifyCenter"
                                            layedit-event="center"></i>
                                        <i class="layui-icon
                                                layedit-tool-right" title="右对齐" lay-command="justifyRight"
                                            layedit-event="right"></i>
                                        <i class="layui-icon
                                                layedit-tool-link" title="插入链接" layedit-event="link"></i>
                                        <i class="layui-icon
                                                layedit-tool-unlink
                                                layui-disabled" title="清除链接" lay-command="unlink"
                                            layedit-event="unlink"></i>
                                        <i class="layui-icon
                                                layedit-tool-image" title="图片" layedit-event="image">
                                            <input type="file" name="file" />
                                        </i>
                                    </div>
                                    <div class="layui-layedit-iframe">
                                        <iframe id="update_info" name="update_info" textarea="update_info"
                                            frameborder="0" style="height: 100px"></iframe>
                                    </div>
                                </div>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
            <div class="layui-form-item" style="padding-left: 10px">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal" data-type="pushData" type="button" lay-submit=""
                        lay-filter="formDemo">
                        立即提交
                    </button>

                </div>
            </div>
        </form>
    </div>
    <script src="/static/admin/layui/layui.js" type="text/javascript" charset="utf-8"></script>
    <script src="/static/admin/js/common.js" type="text/javascript" charset="utf-8"></script>
    <script>
        var $ = layui.jquery;
        $(".NumDecText").keyup(function () {
            $(this).val($(this).val().replace(/[^0-9.]/g, ''));
        }).bind("paste", function () {  //CTR+V事件处理    
            $(this).val($(this).val().replace(/[^0-9.]/g, ''));
        }).css("ime-mode", "disabled"); //CSS设置输入法不可用    

        layui.use(
            [
                "form",
                "jquery",
                "laydate",
                "layer",
                "laypage",
                "dialog",
                "element",
                "upload",
                "layedit",
            ],
            function () {
                var form = layui.form,
                    layer = layui.layer,
                    $ = layui.jquery,
                    laypage = layui.laypage,
                    laydate = layui.laydate,
                    layedit = layui.layedit,
                    element = layui.element,
                    dialog = layui.dialog,
                    upload = layui.upload;
                //获取当前iframe的name值
                var iframeObj = $(window.frameElement).attr("name");
                //创建一个编辑器
                var editIndex = layedit.build("update_info", {
                    tool: [
                        "strong", //加粗
                        "italic", //斜体
                        "underline", //下划线
                        "del", //删除线
                        "|", //分割线
                        "left", //左对齐
                        "center", //居中对齐
                        "right", //右对齐
                        "link", //超链接
                        "unlink", //清除链接
                        "image", //插入图片
                    ],
                    height: 100,
                });

                var active = {
                    pushData: function () {
                        var platform = $("#platform").val();//类型 
                        var key = $("#key").val();//密钥
                        var private_key = $("#private_key").val();//私钥
                        var version = $("#version").val();//版本
                        var build_version = $("#build_version").val();//编译版本
                        var download_url = $("#download_url").val();//编译版本
                        var update_info = layedit.getContent(editIndex);//更新日志

                        if (!platform) {
                            alert('类型 不能为空');
                            return;
                        }
                        if (!key) {
                            alert('密钥 不能为空');
                            return;
                        }
                        if (!private_key) {
                            alert('私钥 不能为空');
                            return;
                        }
                        if (!version) {
                            alert('版本 不能为空');
                            return;
                        }
                        if (!build_version) {
                            alert('编译版本 不能为空');
                            return;
                        }
                        if (!update_info) {
                            alert('更新日志 不能为空');
                            return;
                        }
                        if (!download_url) {
                            alert('下载地址 不能为空');
                            return;
                        }

                        requestData(
                            "/<?php echo htmlentities($useradmin); ?>/App/AppSetting/SaveAppInfo", {
                            "platform": platform,
                            "key": key,
                            "private_key": private_key,
                            "version": version,
                            "build_version": build_version,
                            "update_info": update_info,
                            "download_url": download_url,
                        },
                            (e) => {
                                if (e.code == 200) {
                                    window.location.replace("/<?php echo htmlentities($useradmin); ?>/App/AppSetting/AppList.html");
                                } else {
                                    layer.open({
                                        type: 0,
                                        skin: 'layui-layer-demo', //样式类名
                                        title: "发生错误 错误代码" + e.code,
                                        closeBtn: 0, //不显示关闭按钮
                                        anim: 2,
                                        maxWidth: '7%',
                                        maxHeight: '70%',
                                        shadeClose: false, //开启遮罩关闭
                                        content: '<div style="max-width:100%">' +
                                            '<li style="text-align:center;" class="layer-area">' +
                                            '<div style="text-align:center;">' +
                                            '<img  draggable="false" style="max-Width:70%;max-height:60%;" src="https://i0.hdslb.com/bfs/album/89f61ba7b2456dfd5af4bd92b485553274f73ad4.png">' +
                                            '<div style="text-align:center;">' +
                                            '<font>' + e.message + '</font>' +
                                            '<font> 建议处理方法<p style="color:red">' + e.detail + '</p></font>' +
                                            '</div>' +
                                            '</div>' +
                                            '</li>' +
                                            '</div>',
                                        btn: ['确认',] //可以无限个按钮
                                        ,
                                        btn1: function (index, layero) {
                                            window.location.reload();
                                        }
                                    });
                                }
                                layer.close(loginTips);
                            }
                        );
                    }
                }

                $('.layui-btn-normal').on('click', function () {
                    var type = $(this).data('type');
                    active[type] ? active[type].call(this) : '';
                });

                //全选
                form.on("checkbox(allChoose)", function (data) {
                    var child = $(data.elem)
                        .parents("table")
                        .find('tbody input[type="checkbox"]');
                    child.each(function (index, item) {
                        item.checked = data.elem.checked;
                    });
                    form.render("checkbox");
                });
                form.render();

                upload.render({
                    elem: "#update-file",
                    url: " /<?php echo htmlentities($useradmin); ?>/update/updateFile",
                    done: function (res) {
                        //上传后的回调
                        if (res.code == 200) {
                            $FileUrl = res.data.fileSrc;
                            $("#download_url").val($FileUrl);
                        }
                    },
                    error: function (index, upload) {
                        alert('文件上传失败请重新上传')
                    },
                    accept: "file", //允许上传的文件类型
                });
            }
        );
    </script>
    <iframe id="layui-upload-iframe" class="layui-upload-iframe" name="layui-upload-iframe"></iframe>
</body>

</html>